<?php
include "include/config.inc.php";
$guaranterArray = array();
$i = 0;
$selectGuaranter = "SELECT loanId, loan.guaranterId, a.partyName AS guaranterName, b.partyName, loanDate, loanAmount
                      FROM loan
                 LEFT JOIN party a ON a.partyId = loan.guaranterId
                 LEFT JOIN party b ON b.partyId = loan.partyId
                     ORDER BY guaranterId";
$selectGuaranterRes = mysql_query($selectGuaranter);
while($guaranterRow = mysql_fetch_array($selectGuaranterRes))
{
  $guaranterArray[$i]['loanId'] = $guaranterRow['loanId']; 
  $guaranterArray[$i]['guaranterName'] = $guaranterRow['guaranterName']; 
  $guaranterArray[$i]['partyName']     = $guaranterRow['partyName'];
  $guaranterArray[$i]['loanDate']      = $guaranterRow['loanDate'];
  $guaranterArray[$i]['loanAmount']    = $guaranterRow['loanAmount'];
  $i++;
}

$smarty -> assign('guaranterArray', $guaranterArray);
$smarty ->display("guaranterDisplay.tpl");
?>